package com.itheima.day11.bytestream.test7;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        // 创建字符输入流
        FileInputStream fis = null;
        // 创建字符输出流
        FileOutputStream fos = null;

        try {
            fis = new FileInputStream("myCode\\src\\com\\itheima\\day11\\a.txt");
            fos = new FileOutputStream("myCode\\src\\com\\itheima\\day11\\b.txt", true);
            int read;
            while ((read = fis.read()) != -1) {
                fos.write(read);
            }
        } catch (FileNotFoundException e) {
            System.out.println("没找到文件");
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("奇怪的问题又出现了");
            e.printStackTrace();
        } finally {
            if (fis != null) {
                try {
                    System.out.println("fis释放资源");
                    fis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (fos != null) {
                try {
                    System.out.println("fos释放资源");
                    fos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
